from typing import List

import uvicorn
from fastapi import FastAPI, HTTPException

import calculater
from params import *

app = FastAPI()


@app.post("/gisapi/{category}")
def calc(category: str, pieces: List[Piece]):
    if BoardCategory[category] is None:
        raise HTTPException(status_code=400, detail="path variable category not match")
    calculater.calc[BoardCategory[category]](pieces)
    return {"category": category, "pieces": pieces}


if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)
